package com.lx.core.config;

import com.alibaba.dubbo.config.spring.ReferenceBean;
import com.lx.constants.CommonConstants;

import com.lx.demo.b.interfaces.TestDemoBDubboService;
import com.lx.demo.interfaces.TestDubboDemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by lanyxp on 2021/2/23 10:35
 *
 * @desc: 推荐使用 com.alibaba.dubbo.config.annotation.Reference注解
 * Apache Dubbo 不推荐使用 ReferenceBean<T> 进行消费初始化服务引用
 * @see:https://www.codingw.net/article?id=773 {@link com.alibaba.dubbo.config.annotation.Reference}
 * @desc:<p>后期删除</p>
 */
@Slf4j
@Configuration
@Deprecated
public class DubboConfig {
    /***
     *<br>服务消费 配置生成器</br>
     * @param interfaces
     * @param <T>
     * @return
     */
    @Deprecated
    private <T> ReferenceBean<T> createReferenceBean(Class<T> interfaces) {
        ReferenceBean referenceBean = new ReferenceBean();
        referenceBean.setInterface(interfaces);
        referenceBean.setCheck(Boolean.FALSE);
        referenceBean.setOwner(CommonConstants.DUBO_OWNER);
        referenceBean.setTimeout(CommonConstants.DUBO_TIME);
        referenceBean.setGroup(CommonConstants.DUBO_GROUP);
        referenceBean.setVersion(CommonConstants.DUBO_VERSION);
        return referenceBean;
    }
    /***
     * 配置dubbo服务Demo
     * @return
     *//*
    @Bean
    public ReferenceBean<TestDubboDemoService> testDubboDemoServiceReferenceBean() {
        return this.createReferenceBean(TestDubboDemoService.class);
    }

    *//***
     * 配置Dubbo服务B
     * @return
     *//*
    @Bean
    public ReferenceBean<TestDemoBDubboService> testDemoBDubboServiceReferenceBean() {
        return this.createReferenceBean(TestDemoBDubboService.class);
    }*/
}